- status = commit.status
%tr.commit
  %td.commit-link
    = link_to namespace_project_pipeline_path(@project.namespace, @project, commit.id), class: "ci-status ci-#{status}" do
      = ci_icon_for_status(status)
      %strong ##{commit.id}

  %td
    %div.branch-commit
      - if commit.ref
        = link_to commit.ref, namespace_project_commits_path(@project.namespace, @project, commit.ref), class: "monospace"
        &middot;
      = link_to commit.short_sha, namespace_project_commit_path(@project.namespace, @project, commit.sha), class: "commit-id monospace"
      &nbsp;
      - if commit.tag?
        %span.label.label-primary 标签
      - elsif commit.latest?
        %span.label.label-success.has-tooltip{ title: '此分支最新的构建' } 最新的
      - if commit.triggered?
        %span.label.label-primary 被触发
      - if commit.yaml_errors.present?
        %span.label.label-danger.has-tooltip{ title: "#{commit.yaml_errors}" } yaml 无效
      - if commit.builds.any?(&:stuck?)
        %span.label.label-warning 卡住

      %p.commit-title
        - if commit_data = commit.commit_data
          = link_to_gfm truncate(commit_data.title, length: 60), namespace_project_commit_path(@project.namespace, @project, commit_data.id), class: "commit-row-message"
        - else
          无法找到此分支的 HEAD 提交


    - stages_status = commit.statuses.stages_status
    - stages.each do |stage|
      %td
        - status = stages_status[stage]
        - tooltip = "#{ci_stage_zh(stage)}：#{ci_status_zh(status) || '未发现'}"
        - if status
          = link_to namespace_project_pipeline_path(@project.namespace, @project, commit.id, anchor: stage), class: "has-tooltip ci-status-icon-#{status}", title: tooltip do
            = ci_icon_for_status(status)
        - else
          .light.has-tooltip{ title: tooltip }
            \-

  %td
    - if commit.started_at && commit.finished_at
      %p.duration
        #{duration_in_words(commit.finished_at, commit.started_at)}

  %td
    .controls.hidden-xs.pull-right
      - artifacts = commit.builds.latest.select { |b| b.artifacts? }
      - if artifacts.present?
        .dropdown.inline.build-artifacts
          %button.dropdown-toggle.btn{type: 'button', 'data-toggle' => 'dropdown'}
            = icon('download')
            %b.caret
          %ul.dropdown-menu.dropdown-menu-align-right
            - artifacts.each do |build|
              %li
                = link_to download_namespace_project_build_artifacts_path(@project.namespace, @project, build), rel: 'nofollow' do
                  = icon("download")
                  %span #{build.name}

      - if can?(current_user, :update_pipeline, @project)
        - if commit.retryable? && commit.builds.failed.any?
          = link_to retry_namespace_project_pipeline_path(@project.namespace, @project, commit.id), class: 'btn has-tooltip', title: "重试", method: :post do
            = icon("repeat")
        - if commit.active?
          = link_to cancel_namespace_project_pipeline_path(@project.namespace, @project, commit.id), class: 'btn btn-remove has-tooltip', title: "取消", method: :post do
            = icon("remove")
